#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<element.h>
#include<double_linked_list.h>

struct element * creat_element(char * data){
    struct element * elem=(struct element *)malloc(sizeof(struct element));
    int data_len=strlen(data);
    elem->data=(char *)malloc((data_len+1)*sizeof(char));
    strcpy(elem->data,data);
    elem->next=NULL;
    elem->prev=NULL;
    return elem;
}

void print_element(struct element * elem){
    printf("data:%s \t prev:%p \t next:%p \n",elem->data,elem->prev,elem->next);

}

int delete_element(struct element * elem){
    if(elem==NULL) return -1;
    else if(elem->data==NULL){
        free(elem);
        elem=NULL;
        return 0;
    }else{
        free(elem->data);
        elem->data=NULL;
        free(elem);
        elem=NULL;
        return 0;
    }
}
